package cool.tenyears.controller;

import cn.hutool.core.lang.tree.Tree;
import cool.tenyears.core.domain.RL;
import cool.tenyears.domain.Menu;
import cool.tenyears.service.MenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LiChuan
 * @date 2021/6/29 12:39
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sys/menu")
public class MenuController {
    private final MenuService menuService;

    /**
     * 查询菜单树
     * @param menu 菜单
     * @return 树
     */
    @GetMapping("/tree")
    public RL<Tree<String>> menuList(Menu menu) {
        List<Tree<String>> trees = menuService.treeMenu(menu);
        return RL.list(trees);
    }
}
